package my.test.proxyPattern.aop;

import my.test.proxyPattern.GamePlayer;
import my.test.proxyPattern.IGamePlayer;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Client {

    public static void main(String[] args) {
        IGamePlayer player = new GamePlayer("张三");
        InvocationHandler handler = new GamePlayIH(player);
        //开始打游戏
        System.out.println("开始时间为：2018-8-25 10:45");
        ClassLoader c1 = player.getClass().getClassLoader();
        //动态产生一个代理者
        IGamePlayer proxy = (IGamePlayer) Proxy.newProxyInstance(c1, new Class[]{IGamePlayer.class}, handler);
        proxy.login("迪迦", "123456");
        proxy.killBoss();
        proxy.upgrade();
        System.out.println("结束时间为：2018-8-25 12:45");
    }
}
